<template>
	<view class="pb">
		<view class="text-center mt20"><image class="head_img" :src="infoData.baseInfo.head_img" mode="widthFix"></image></view>
		<view class="p0-15">
			<uni-title type="h2" :title="infoData.baseInfo.name"></uni-title>
			<view class="user-info">{{infoData.baseInfo.sex == 1 ? '男' : '女'}} | {{infoData.baseInfo.age}} | {{infoData.baseInfo.area}}</view>
		</view>
		<uni-section :title="'电话：'+infoData.baseInfo.mobilephone_">
			<template v-slot:decoration>
				<view class="decoration"></view>
			</template>
		</uni-section>
		<uni-section :title="'邮箱：'+infoData.baseInfo.email_">
			<template v-slot:decoration>
				<view class="decoration"></view>
			</template>
		</uni-section>
		<uni-section title="求职意向" :sub-title="infoData.baseInfo.position">
			<template v-slot:decoration>
				<view class="decoration"></view>
			</template>
		</uni-section>
		<uni-section title="期望薪资" :sub-title="infoData.baseInfo.salary">
			<template v-slot:decoration>
				<view class="decoration"></view>
			</template>
		</uni-section>
		<view class="view-line"></view>
		<uni-section title="工作经验">
			<template v-slot:decoration>
				<view class="decoration"></view>
			</template>
		</uni-section>
		<view class="p0-15-15-15" v-for="item in infoData.WorkList" :key="item.id">
			<uni-title type="h2" :title="item.ccompname"></uni-title>
			<view class="fz09rem">{{item.timefrom}} - {{item.timeto}}</view>
			<uni-title type="h3" :title="item.cposition"></uni-title>
			<view class="mt5">行业：{{item.workindustry}}</view>
			<view class="mt5">描述：{{item.cworkdescribe}}</view>
			<view class="mt5">业绩：{{item.performance}}</view>
		</view>
		
		<view class="view-line"></view>
		<uni-section title="项目经验">
			<template v-slot:decoration>
				<view class="decoration"></view>
			</template>
		</uni-section>
		<view class="p0-15-15-15" v-for="item in infoData.project" :key="item.id">
			<uni-title type="h2" :title="item.cprojectname"></uni-title>
			<view class="fz09rem">{{item.starttime}} - {{item.endtime}}</view>
			<view class="mt5">{{item.post}}{{item.costs}}</view>
			<view class="mt5">公司：{{item.ccompname}}</view>
			<view class="mt5">描述：{{item.cdescribe}}</view>
		</view>
		
		<view class="view-line"></view>
		<uni-section title="教育经历">
			<template v-slot:decoration>
				<view class="decoration"></view>
			</template>
		</uni-section>
		<view class="p0-15-15-15" v-for="item in infoData.education" :key="item.id">
			<uni-title type="h2" :title="item.cschoolname"></uni-title>
			<view class="fz09rem">{{item.timefrom}} - {{item.timeto}}</view>
			<view class="mt5">专业：{{item.cmajordes}}</view>
			<view class="mt5">描述：{{item.cdescribe}}</view>
		</view>
		
		<view class="view-line"></view>
		<uni-section title="培训经历">
			<template v-slot:decoration>
				<view class="decoration"></view>
			</template>
		</uni-section>
		<view class="p0-15-15-15" v-for="item in infoData.skillTrain" :key="item.id">
			<uni-title type="h2" :title="item.ctrainname"></uni-title>
			<view class="fz09rem">{{item.timefrom}} - {{item.timeto}}</view>
			<view class="mt5">专业：{{item.ctrainlesson}};地区：{{item.ctrainplace}}</view>
			<view class="mt5">描述：{{item.cdescribe}}</view>
		</view>
		
		<view class="view-line"></view>
		<uni-section title="证书">
			<template v-slot:decoration>
				<view class="decoration"></view>
			</template>
		</uni-section>
		<view class="p0-15-15-15" v-for="item in infoData.cert" :key="item.id">
			<uni-title type="h2" :title="item.certname"></uni-title>
			<view class="fz09rem">{{item.getdate}}</view>
			<view class="mt5">成绩：{{item.score}}</view>
		</view>
		
		
		<view class="fixed-bottom">
			<uni-goods-nav :fill="true" :options="options" :button-group="customButtonGroup" @click="onClickOption" @buttonClick="buttonClick" />
		</view>
		
		<uni-popup ref="popupCustomer" background-color="none">
			<customerVue></customerVue>
		</uni-popup>
		
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog type="center" cancelText="关闭" confirmText="拨号" title="联系方式" :content="infoData.baseInfo.mobilephone" @confirm="dialogConfirm"
				@close="dialogClose"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import customerVue from '../../components/customer.vue'
	export default {
		components: {
			customerVue
		},
		data() {
			return {
				form:{resume_id:0,user_id:0},
				infoData:{
					WorkList: [],
					attach: [],
					baseInfo: {name:'',age:0,area:0,mobilephone:'',email:''},
					cert: [],
					education: [],
					evaluate: "",
					phone_list: [],
					project: [],
					score: 3,
					skillTrain: [],
					skilllanguage: [],
					workExpect: {},
				},
				
				options: [{
					icon: 'paperplane',
					text: '咨询',
					type:'paperplane',
				}],
				customButtonGroup: [
					{ icon: 'shop',text: '获取联系方式', backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)', color: '#333' },
				],
				
				shareinfo:{title:'',img:'',path:''}
			}
		},
		onLoad(options){
			this.form.resume_id = options.resume_id
			this.form.user_id = options.user_id
			this.onGetData()
		},
		methods: {
			onGetData(){
				let _this = this
				this.$request('/api/companyRead','POST',this.form).then(res => {
					_this.infoData = res.data
					_this.infoData.baseInfo.mobilephone_ = _this.infoData.baseInfo.mobilephone.substr(0,7)+'****'
					_this.infoData.baseInfo.email_ = '****'+_this.infoData.baseInfo.email.slice(4)
					if(res.data.workExpect){
						_this.infoData.baseInfo.position = res.data.workExpect.position
						_this.infoData.baseInfo.salary_type = res.data.workExpect.salary_type
						_this.infoData.baseInfo.salary = _this.$func.scale[res.data.workExpect.salary]
						
						_this.infoData.baseInfo.salary = res.data.workExpect.salary_type == 2 ? _this.$func.month_wages[res.data.workExpect.salary] : _this.$func.year_wages[res.data.workExpect.salary]
						_this.infoData.baseInfo.salary_type = res.data.workExpect.salary_type == 2 ? '月' : '年'
					}
					
					_this.shareinfo.title = _this.infoData.baseInfo.name+'的简历'
					_this.shareinfo.img = _this.infoData.baseInfo.head_img
				}).catch(err => {
					console.log(err)
				})
			},
			onClickOption(e){
				if(e.content.type == 'paperplane'){
					this.$refs.popupCustomer.open('center')
				}
			},
			buttonClick(e) {
				//判断是否是vip
				let _this = this
				this.$request_api('applet_api/isvip','POST',{}).then(res => {
					if(res.code != 200){
						uni.showToast({title: '您还不是vip无法查看,请购买套餐,',icon: 'error',duration: 2000})
						return;
					}
					
					if(res.data.indexOf('resume') < 0){
						uni.showToast({title: '您的vip套餐不支持查看,请购买套餐,',icon: 'error',duration: 2000})
						return;
					}
					this.$refs.alertDialog.open('center')
					return;
					
				}).catch(err => {
					console.log(err)
				})
				
			},
			dialogConfirm(){
				uni.makePhoneCall({
					phoneNumber: this.infoData.baseInfo.mobilephone,
				});
			},
			dialogClose(){
				
			},
			onLink(url,id){
				
			}
		}
	}
</script>

<style scoped lang="scss">
.head_img{width: 120px;height: 120px;}
.user-info{margin-top: 5px;font-size: .9rem;color: #666;}
</style>
